package yja.gzw.app.activity

import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import android.widget.Toast
import com.baidu.oauth.sdk.auth.BdSsoHandler
import com.baidu.oauth.sdk.callback.BdOauthCallback
import com.baidu.oauth.sdk.dto.BdOauthDTO
import com.baidu.oauth.sdk.result.BdOauthResult
import com.bytedance.sdk.open.aweme.authorize.model.Authorization
import com.bytedance.sdk.open.douyin.DouYinOpenApiFactory
import yja.gzw.app.R
import yja.gzw.app.base.BaseActivity
import yja.gzw.app.databinding.ActivityShezhiBinding
import yja.gzw.app.viewmodel.Mainviewmodel
import java.util.UUID


class ShezhiActivity :BaseActivity<Mainviewmodel, ActivityShezhiBinding>(R.layout.activity_shezhi){
    var sp: SharedPreferences?=null
        //todo 百度授权暂且处理
    override fun initView() {
        binding.fanhui.setOnClickListener {
            finish()
        }
        binding.qiyeshangfengrz.setOnClickListener {
            //todo 百度授权代码开始
//             val bdSsoHandler = BdSsoHandler(this);
//            val bdOauthDTO = BdOauthDTO()
////            BdOauthDTO.OAUTH_TYPE_BOTH
//            BdOauthDTO.OAUTH_TYPE_WEB
//
//            bdOauthDTO.oauthType = BdOauthDTO.OAUTH_TYPE_BOTH;
//
//            bdOauthDTO.state = UUID.randomUUID().toString()
//            bdSsoHandler.authorize(bdOauthDTO, object : BdOauthCallback() {
//                override fun onSuccess(result: BdOauthResult) {
//                   Toast.makeText(this@ShezhiActivity,"code = " + result.code + " state = " + result.state,Toast.LENGTH_SHORT).show()
//                    //Toast.makeText(this@ShezhiActivity,"fsafs", Toast.LENGTH_SHORT).show()
//                }
//
//                override fun onFailure(result: BdOauthResult) {
//                    Toast.makeText(this@ShezhiActivity,"result code = " + result.resultCode + " msg = " + result.resultMsg,Toast.LENGTH_SHORT).show()
//                }
//            })
//todo 百度授权代码结束

            val intent=Intent(this,QianyazhanshiActivity::class.java)
            startActivity(intent)
        }
        binding.xiaoxishezhi.setOnClickListener {
            val inten =Intent(this,XiaoxishezhiActivity::class.java)
            startActivity(inten)


        }



            binding.yingsizhengce.setOnClickListener {

                val inten=Intent(this,YingsizhangzeActivity::class.java)
                startActivity(inten)
            }

            binding.tongyongshezhi.setOnClickListener {
                val intent=Intent(this,TongyongshezhiActivity::class.java)
                startActivity(intent)
            }

            binding.fankuiyujianyi.setOnClickListener {
                val inte=Intent(this,FankuiActivity::class.java)
                startActivity(inte)

            }
        binding.zhanghaoanquan.setOnClickListener {
            //todo 抖音授权代码开始
//            val douyinOpenApi = DouYinOpenApiFactory.create(this)
//            val request = Authorization.Request()
//           // request.scope = "user_info"
//            request.scope = "trial.whitelist"
//            request.callerLocalEntry = "yja.gzw.app.DouYinEntryActivity"
//            douyinOpenApi.authorize(request)
            //todo 抖音授权代码结束
         val inten =Intent(this,ZhanghaoanquanActivity::class.java)
        startActivity(inten)

        }

        sp = this.getSharedPreferences("Shujuku", Context.MODE_PRIVATE)
        binding.tuichudenglu.setOnClickListener {

            sp?.edit()?.putBoolean("islogin",false)?.apply()

            val intent = Intent(this,LogActivity::class.java)
            finish()
            startActivity(intent)  // 启动 SecondActivity


        }

            binding.guanyuwomeng.setOnClickListener {

                val intent=Intent(this,GuanyuwomengActivity::class.java)
                startActivity(intent)

            }

        binding.yingsishezhi.setOnClickListener {

            val inten=Intent(this,YinsisehzhiActivity::class.java)
            startActivity(inten)
        }
        binding.shouhuoriqi.setOnClickListener {
            val intent=Intent(this,ShouhuoroqiActivity::class.java)
            startActivity(intent)

        }

    }

    override fun dataObservese() {

    }
}